/**
 * 初始化类库
 */
(function (win, doc) {
    /**
     * 设置包路径
     */
    var jsSelf = (function () {
        var files = doc.getElementsByTagName('script');
        return files[files.length - 1];
    })();
    window.packagePath = jsSelf.getAttribute('data-path');
    window.rootUrl = jsSelf.getAttribute('data-root');
    window.roleName = jsSelf.getAttribute('data-role');
    window.tplPath = jsSelf.getAttribute('data-tpl');
    window.commonPath = '//cdn.duxphp.com/duxjs/js/';
    var source = jsSelf.getAttribute('data-source');
    if(source == null) {
        source = false;
    }
    window.source = source;
    var debug = jsSelf.getAttribute('data-debug');
    if(debug == null) {
        debug = false;
    }
    window.debug = debug;
    window.mobile = false;

    /**
     * 公共类
     */
    Do.add('common', {
        path: commonPath + 'common.min.js?v=2.0',
        type : 'js'
    });

    Do.add('chart', {
        path: '//cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.js',
        type: 'js'
    });

    /**
     * 表单
     */
    Do.add('validator', {
        path: commonPath + 'package/form/validator.js',
        type: 'js'
    });
    Do.add('form', {
        path: '//cdnjs.cloudflare.com/ajax/libs/jquery.form/4.2.2/jquery.form.js',
        requires: ['validator'],
        type: 'js'
    });

    /**
     * 上传
     */
    Do.add('uploadSrc', {
        path: '//cdnjs.cloudflare.com/ajax/libs/plupload/3.1.2/plupload.full.min.js'
    });
    Do.add('upload', {
        path: '//cdnjs.cloudflare.com/ajax/libs/plupload/3.1.2/i18n/zh_CN.js',
        requires: ['uploadSrc']
    });

    /**
     * 模板引擎
     */
    Do.add('tpl', {
        path: commonPath + 'package/tpl/laytpl.js',
        type: 'js'
    });

    /**
     * MD编辑器
     */
    Do.add('editorMdCss', {
        path: '//cdnjs.cloudflare.com/ajax/libs/simplemde/1.11.2/simplemde.min.css',
        type: 'css'
    });
    Do.add('editor_md', {
        path: '//cdnjs.cloudflare.com/ajax/libs/simplemde/1.11.2/simplemde.min.js',
        requires: ['editorMdCss']
    });

    /**
     * 富文本编辑器
     */
    Do.add('editor', {
        path: commonPath + 'package/editor/kindeditor-all-min.js',
    });

    /**
     * 日期选择
     */
    Do.add('date', {
        path: commonPath + 'package/date/laydate.js',
    });

    /**
     * 移动端日期选择
     */
    Do.add('dateCss', {
        path: commonPath + 'package/date_mobile/Jcalendar.css',
        type: 'css'
    });
    Do.add('date_mobile', {
        path: commonPath + 'package/date_mobile/Jcalendar.js',
        requires: ['dateCss']
    });

    /**
     * 地区选择
     */
    Do.add('distpicker', {
        path: '//cdnjs.cloudflare.com/ajax/libs/distpicker/2.0.3/distpicker.min.js'
    });

    /**
     * 地区选择
     */
    Do.add('distpickerData', {
        path: commonPath + 'package/distpicker_mobile/city.js'
    });
    Do.add('distpickerCss', {
        path: commonPath + 'package/distpicker_mobile/MultiPicker.css',
        type: 'css'
    });
    Do.add('distpicker_mobile', {
        path: commonPath + 'package/distpicker_mobile/MultiPicker.js',
        requires: ['distpickerCss', 'distpickerData']
    });

    /**
     * TAG输入
     */
    Do.add('tags', {
        path: '//cdnjs.cloudflare.com/ajax/libs/jquery-tagsinput/1.3.6/jquery.tagsinput.min.js'
    });

    /**
     * 下拉增强
     */
    Do.add('select2Css', {
        path: '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.1/css/select2.min.css',
        type: 'css'
    });
    Do.add('select2Src', {
        path: '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.1/js/select2.full.min.js'
    });
    Do.add('select2', {
        path: '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.1/js/i18n/zh-CN.js',
        requires: ['select2Src', 'select2Css']
    });

    /**
     * 打印
     */
    Do.add('print', {
        path: '//cdnjs.cloudflare.com/ajax/libs/jQuery.print/1.5.1/jQuery.print.min.js'
    });

    /**
     * 复制
     */
    Do.add('copy', {
        path : '//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.3.0/ZeroClipboard.min.js'
    });

    /**
     * 下拉刷新
     */
    Do.add('mescrollCss', {
        path: commonPath + 'package/mescroll/mescroll.min.css',
        type: 'css'
    });
    Do.add('mescroll', {
        path: commonPath + 'package/mescroll/mescroll.min.js',
        requires: ['mescrollCss']
    });


    /**
     * 图表
     */
    Do.add('shareCss', {
        path: commonPath + 'package/share/css/share.min.css',
        type: 'css'
    });
    Do.add('share', {
        path: commonPath + 'package/share/js/share.min.js',
        type: 'js',
        requires: ['shareCss']
    });

    /**
     * 腾讯地图
     */
    Do.add('tmap', {
        path: '//map.qq.com/api/js?v=2.exp&callback=tmapInit',
        type: 'js'
    });

    /**
     * 二维码
     */
    Do.add('qrcode', {
        path: '//cdnjs.cloudflare.com/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js',
        type: 'js'
    });

    /**
     * cookie
     */
    Do.add('cookie', {
        path: '//cdnjs.cloudflare.com/ajax/libs/js-cookie/latest/js.cookie.min.js',
        type: 'js'
    });

    /**
     * fix
     */
    Do.add('inobounce', {
        path: '//cdnjs.cloudflare.com/ajax/libs/inobounce/0.1.6/inobounce.min.js',
        type : 'js'
    });

    /**
     * 滚动
     */
    Do.add('scrollbox', {
        path: commonPath + 'package/slider/jquery.scrollbox.min.js',
        type: 'js'
    });

    /**
     * 幻灯片
     */
    Do.add('owlCss', {
        path: commonPath + 'package/slider/css/owl.carousel.min.css',
        type: 'css'
    });
    Do.add('owl', {
        path: commonPath + 'package/slider/owl.carousel.min.js',
        type: 'js',
        requires: ['owlCss']
    });

    Do.add('echarts', {
        path: '//cdn.bootcss.com/echarts/4.2.0-rc.2/echarts.min.js',
        type: 'js'
    });

    Do.add('color', {
        path:  commonPath + 'package/color/jquery.colorpicker.js',
        type: 'js'
    });


})(window, document);
